package com.athbsd.exer5;

import com.athbsd.exer4.Student;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/**
 * Date:2025/2/24
 * Author：zhouzhou
 * Description:
 */
public class ListTest {
    public static void main(String[] args) {
        List list=new ArrayList<>();
        //随机生产字符
        for (int i=0;i<30;i++){
            list.add((char)(Math.random()*(122-97+1)+97)+"");
        }
        System.out.println(list);
        System.out.println(listTest(list, "a"));
        System.out.println(listTest(list, "b"));
        System.out.println(listTest(list, "c"));
        System.out.println(listTest(list, "d"));
    }

    /**
     * 查找字符s在集合list中存在的次数
     * @param list
     * @param s
     * @return
     */
     public static int listTest(Collection list,String s){
        int count=0;
        for(Object o:list){
            if(o.equals(s)){
                count++;
            }
        }
        return count;
     }
}
